//导入request.js请求工具
import request from '@/utils/request.js'
import { EventSourcePolyfill } from 'event-source-polyfill';
import {useTokenStore} from "@/stores/token.js";
import {baseUrl} from "@/utils/request.js";

export const getAITalkService = () => {
    //为sse请求单独添加请求头
    const tokenStore = useTokenStore();
    const headers = {
        "Authorization": tokenStore.token
    }
    return new EventSourcePolyfill(baseUrl+`/aiTalk`,{headers})
}

export const saveAITalks = (says) => {
    return request.post("/aiTalk", says)
}

export const deleteAiTalk = () => {
    return request.delete(`/aiTalk`)
}

export const getQwenVLService = (imageURL) =>{
    return request({
        url: '/aiTalk/qwenVL',
        method: 'get',
        params: {
            imageURL
        }
    })
}